home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmiSoft / Dev / Mui / Mcc_speedbar.lha / MCC_SpeedBar / Developer / C / Examples / demo3.c < prev    next >
C/C++ Source or Header  |  2002-12-21  |  8KB  |  203 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/datatypes.h>
  5. #include <proto/muimaster.h>
  6. #include <clib/alib_protos.h>
  7. #include <mui/SpeedBar_mcc.h>
  8. #include <mui/SpeedButton_mcc.h>
  9. #include <mui/SpeedBarCfg_mcc.h>
  10. #include <datatypes/pictureclass.h>
  11. #include <string.h>
  12. #include <stdio.h>
  13.  
  14. /***********************************************************************/
  15.  
  16. long __stack = 8192;
  17. struct Library *DataTypesBase;
  18. struct Library *MUIMasterBase;
  19.  
  20. /***********************************************************************/
  21.  
  22. #ifndef MAKE_ID
  23. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  24. #endif
  25.  
  26. /***********************************************************************/
  27.  
  28. struct MUIS_SpeedBar_Button buttons[] =
  29. {
  30.     {0, "_Get", "Get the disc.", 0, NULL},
  31.     {1, "Sa_ve", "Save the disc.", 0, NULL},
  32.     {2, "_Stop", "Stop the connection.", 0, NULL},
  33.     {MUIV_SpeedBar_Spacer},
  34.     {3, "_Disc", "Disc page.", 0, NULL},
  35.     {4, "_Matches", "Matches page.", 0, NULL},
  36.     {5, "_Edit", "Edit page.", 0, NULL},
  37.     {MUIV_SpeedBar_End},
  38. };
  39.  
  40. /***********************************************************************/
  41.  
  42. static Object *
  43. loadDTBrush(struct MyBrush *brush,STRPTR file)
  44. {
  45.     struct BitMapHeader *bmh;
  46.     register Object     *dto;
  47.  
  48.     if (!(dto = NewDTObject(file,DTA_GroupID,GID_PICTURE,PDTA_Remap,FALSE,PDTA_DestMode,PMODE_V42,TAG_DONE)) ||
  49.         !(DoMethod(dto,DTM_PROCLAYOUT,NULL,1)) ||
  50.         !(GetDTAttrs(dto,PDTA_DestBitMap,&brush->BitMap,PDTA_CRegs,&brush->Colors,PDTA_BitMapHeader,&bmh,TAG_DONE)==3))
  51.     {
  52.         if (dto)
  53.         {
  54.             DisposeDTObject(dto);
  55.             dto = NULL;
  56.         }
  57.         brush->BitMap = NULL;
  58.     }
  59.     else
  60.     {
  61.         brush->Width  = bmh->bmh_Width;
  62.         brush->Height = bmh->bmh_Height;
  63.     }
  64.  
  65.     return dto;
  66. }
  67.  
  68. /***********************************************************************/
  69.  
  70. #define TEMPLATE "STRIP,NUMBUTTON/N"
  71.  
  72. int
  73. main(int argc,char **argv)
  74. {
  75.     struct RDArgs   *ra;
  76.     LONG            arg[2] = {0};
  77.     int             res;
  78.  
  79.     if (ra = ReadArgs(TEMPLATE,arg,NULL))
  80.     {
  81.         if (DataTypesBase = OpenLibrary("datatypes.library",37))
  82.         {
  83.             if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  84.             {
  85.                 struct MyBrush                  stripBrush;
  86.                 Object                          *dto, *app, *win, *sb;
  87.                 Object                          *cfg, *update;
  88.                 struct MUIS_SpeedBarCfg_Config  c = {MUIV_SpeedBar_ViewMode_TextGfx, MUIV_SpeedBarCfg_Borderless|MUIV_SpeedBarCfg_Sunny};
  89.                 STRPTR                          stripName;
  90.  
  91.                 stripName = arg[0] ? (char *)arg[0] : "PROGDIR:Pics/Main.toolbar";
  92.  
  93.                 if (!(dto = loadDTBrush(&stripBrush,stripName)))
  94.                     printf("%s: warning can't load '%s'\n",argv[0],stripName);
  95.  
  96.                 if (app = ApplicationObject,
  97.                         MUIA_Application_Title,         "SpeedBar Demo3",
  98.                         MUIA_Application_Version,       "$VER: SpeedBarDemo3 16.1 (3.12.2002)",
  99.                         MUIA_Application_Copyright,     "Copyright 1999-2002 by Alfonso Ranieri",
  100.                         MUIA_Application_Author,        "Alfonso Ranieri <alforan@tin.it>",
  101.                         MUIA_Application_Description,   "Speed(Bar|Button|BarCfg).mcc test",
  102.                         MUIA_Application_Base,          "SPEEDBARTEST",
  103.                         SubWindow, win = WindowObject,
  104.                             MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
  105.                             MUIA_Window_Title,          "SpeedBar Demo3",
  106.                             WindowContents, VGroup,
  107.                                 Child, sb = SpeedBarObject,
  108.                                     GroupFrame,
  109.                                     MUIA_Group_Horiz,               TRUE,
  110.                                     MUIA_SpeedBar_Layout,           MUIV_SpeedBar_Layout_Left,
  111.                                     MUIA_SpeedBar_Borderless,       TRUE,
  112.                                     MUIA_SpeedBar_Sunny,            TRUE,
  113.                                     MUIA_SpeedBar_Buttons,          buttons,
  114.                                     MUIA_SpeedBar_StripUnderscore,  TRUE,
  115.                                     MUIA_SpeedBar_EnableUnderscore, TRUE,
  116.                                     MUIA_SpeedBar_BarSpacer,        TRUE,
  117.                                     MUIA_SpeedBar_StripBrush,       &stripBrush,
  118.                                     MUIA_SpeedBar_StripButtons,     arg[1] ? (*((ULONG *)arg[1])) : 14,
  119.                                 End,
  120.                                 Child, VSpace(0),
  121.                                 Child, VGroup,
  122.                                     GroupFrameT("Appareance"),
  123.                                     Child, cfg = SpeedBarCfgObject,
  124.                                         MUIA_SpeedBarCfg_Config, &c,
  125.                                     End,
  126.                                     Child, VSpace(0),
  127.                                     Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  128.                                 End,
  129.                                 Child, VSpace(0),
  130.                             End,
  131.                         End,
  132.                     End)
  133.                 {
  134.                     ULONG sigs = 0, id;
  135.  
  136.                     DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  137.                     DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  138.  
  139.                     set(win,MUIA_Window_Open,TRUE);
  140.  
  141.                     while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  142.                     {
  143.                         if (id==TAG_USER)
  144.                         {
  145.                             struct MUIS_SpeedBarCfg_Config *c;
  146.  
  147.                             get(cfg,MUIA_SpeedBarCfg_Config,&c);
  148.  
  149.                             SetAttrs(sb,MUIA_SpeedBar_ViewMode,c->ViewMode,
  150.                                         MUIA_SpeedBar_Borderless,c->Flags & MUIV_SpeedBarCfg_Borderless,
  151.                                         MUIA_SpeedBar_RaisingFrame,c->Flags & MUIV_SpeedBarCfg_Raising,
  152.                                         MUIA_SpeedBar_SmallImages,c->Flags & MUIV_SpeedBarCfg_SmallButtons,
  153.                                         MUIA_SpeedBar_Sunny,c->Flags & MUIV_SpeedBarCfg_Sunny,
  154.                                         TAG_DONE);
  155.                         }
  156.  
  157.                         if (sigs)
  158.                         {
  159.                             sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  160.                             if (sigs & SIGBREAKF_CTRL_C) break;
  161.                         }
  162.                     }
  163.  
  164.                     MUI_DisposeObject(app);
  165.  
  166.                     res = RETURN_OK;
  167.                 }
  168.                 else
  169.                 {
  170.                     printf("%s: can't create application\n",argv[0]);
  171.                     res = RETURN_FAIL;
  172.                 }
  173.  
  174.                 if (dto) DisposeDTObject(dto);
  175.                 CloseLibrary(MUIMasterBase);
  176.             }
  177.             else
  178.             {
  179.                 printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  180.                 res = RETURN_ERROR;
  181.             }
  182.  
  183.             CloseLibrary(DataTypesBase);
  184.         }
  185.         else
  186.         {
  187.             printf("%s: can't open datatypes.library ver 37 or higher\n",argv[0]);
  188.             res = RETURN_ERROR;
  189.         }
  190.  
  191.         FreeArgs(ra);
  192.     }
  193.     else
  194.     {
  195.         PrintFault(IoErr(),argv[0]);
  196.         return RETURN_FAIL;
  197.     }
  198.  
  199.     return res;
  200. }
  201.  
  202. /***********************************************************************/
  203.